<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../../vue.js"></script>
  <style>
    .public {
      width: 100px;
      height: 100px;
    }

    .isActive {
      background-color: green;
    }

    .isnoActive {
      background-color: yellow;
    }

    .red {
      color: red
    }

    .fontstyle {
      font-style: italic;
    }

    .fontweight {
      font-weight: bold;
    }
  </style>
</head>

<body>
  <div id="app">
    <!-- 

      1.动态class,值是一个字符串,
      用法:类名只有一个,但不确定是哪一个

      2.动态class,值是一个对象,key是类名,值是布尔值
      用法:类固定,但不确定用不用

      3.data中保存多个数据(布尔值),对象书写在class上,key是类名,值是对应的数据

      4.动态class,值是一个数组,数组中是类名
      用法:类固定,可以对类名进行增删改

      5.class中可以只书写一个变量,变量的值是字符串(属性名)

     -->
    <div class="public" :class="active?'isActive':'isnoActive'">box1</div>
    <div class="public" :class="box2css">box2</div>
    <div class="public" :class="{red:red,fontstyle:fontstyle,fontweight:fontweight}">box3</div>
    <div class="public" :class="box4css">box4</div>


    <div class="public" :class="red">box5</div>
  </div>
  <script>
    Vue.config.productionTip = false
    const vm = new Vue({
      el: "#app",
      data() {
        return {
          msg: "hello vue",
          active: true,
          box2css: {
            red: true,
            fontstyle: true,
            fontweight: true
          },
          red: true,
          fontstyle: true,
          fontweight: true,
          box4css: ['red', 'fontstyle'],
          red:'red'
        }
      }
    })
  </script>
</body>

</html>